﻿using System;
using System.ComponentModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Kaesoft.Hospedaje.Entities;

namespace Kaesoft.Hospedaje.Proxy.DatosReglasReference
{
    public partial class ServicioDatosReglasClient
    {
        public void ObtenerServiciosAsync(Action<ObtenerServiciosCompletedEventArgs> method)
        {
            if ((this.onBeginObtenerServiciosDelegate == null))
            {
                this.onBeginObtenerServiciosDelegate = new BeginOperationDelegate(this.OnBeginObtenerServicios);
            }
            if ((this.onEndObtenerServiciosDelegate == null))
            {
                this.onEndObtenerServiciosDelegate = new EndOperationDelegate(this.OnEndObtenerServicios);
            }

            System.Threading.SendOrPostCallback customObtenerCatalogosDelegate = new System.Threading.SendOrPostCallback(
            state =>
            {
                if (method != null)
                {
                    InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                    ObtenerServiciosCompletedEventArgs eventArg = new ObtenerServiciosCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState);
                    if (!WcfProxyInvoker.ExistenErroresAsync(eventArg.Error))
                        Deployment.Current.Dispatcher.BeginInvoke(method, eventArg);
                }
            }
            );

            base.InvokeAsync(this.onBeginObtenerServiciosDelegate, null, this.onEndObtenerServiciosDelegate, customObtenerCatalogosDelegate, null);
        }

        public void ObtenerHabitacionesAsync(Action<ObtenerHabitacionesCompletedEventArgs> method)
        {
            if ((this.onBeginObtenerHabitacionesDelegate == null))
            {
                this.onBeginObtenerHabitacionesDelegate = new BeginOperationDelegate(this.OnBeginObtenerHabitaciones);
            }
            if ((this.onEndObtenerHabitacionesDelegate == null))
            {
                this.onEndObtenerHabitacionesDelegate = new EndOperationDelegate(this.OnEndObtenerHabitaciones);
            }

            System.Threading.SendOrPostCallback customObtenerCatalogosDelegate = new System.Threading.SendOrPostCallback(
            state =>
            {
                if (method != null)
                {
                    InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                    ObtenerHabitacionesCompletedEventArgs eventArg = new ObtenerHabitacionesCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState);
                    if (!WcfProxyInvoker.ExistenErroresAsync(eventArg.Error))
                        Deployment.Current.Dispatcher.BeginInvoke(method, eventArg);
                }
            }
            );

            base.InvokeAsync(this.onBeginObtenerHabitacionesDelegate, null, this.onEndObtenerHabitacionesDelegate, customObtenerCatalogosDelegate, null);
        }

        public void ObtenerHabitacionAsync(int idHabitacion, Action<ObtenerHabitacionCompletedEventArgs> method)
        {
            if ((this.onBeginObtenerHabitacionDelegate == null))
            {
                this.onBeginObtenerHabitacionDelegate = new BeginOperationDelegate(this.OnBeginObtenerHabitacion);
            }
            if ((this.onEndObtenerHabitacionDelegate == null))
            {
                this.onEndObtenerHabitacionDelegate = new EndOperationDelegate(this.OnEndObtenerHabitacion);
            }

            System.Threading.SendOrPostCallback customObtenerCatalogosDelegate = new System.Threading.SendOrPostCallback(
            state =>
            {
                if (method != null)
                {
                    InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                    ObtenerHabitacionCompletedEventArgs eventArg = new ObtenerHabitacionCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState);
                    if (!WcfProxyInvoker.ExistenErroresAsync(eventArg.Error))
                        Deployment.Current.Dispatcher.BeginInvoke(method, eventArg);
                }
            }
            );

            base.InvokeAsync(this.onBeginObtenerHabitacionDelegate, 
                new object[] { idHabitacion }, this.onEndObtenerHabitacionDelegate, customObtenerCatalogosDelegate, null);
        }

        public void ObtenerHabitacionesPaginadoAsync(int tipoConsulta, string criterio, int indice, Action<ObtenerHabitacionesPaginadoCompletedEventArgs> method)
        {
            if ((this.onBeginObtenerHabitacionesPaginadoDelegate == null))
            {
                this.onBeginObtenerHabitacionesPaginadoDelegate = new BeginOperationDelegate(this.OnBeginObtenerHabitacionesPaginado);
            }
            if ((this.onEndObtenerHabitacionesPaginadoDelegate == null))
            {
                this.onEndObtenerHabitacionesPaginadoDelegate = new EndOperationDelegate(this.OnEndObtenerHabitacionesPaginado);
            }

            System.Threading.SendOrPostCallback customObtenerCatalogosDelegate = new System.Threading.SendOrPostCallback(
            state =>
            {
                if (method != null)
                {
                    InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                    ObtenerHabitacionesPaginadoCompletedEventArgs eventArg = new ObtenerHabitacionesPaginadoCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState);
                    if (!WcfProxyInvoker.ExistenErroresAsync(eventArg.Error))
                        Deployment.Current.Dispatcher.BeginInvoke(method, eventArg);
                }
            }
            );

            base.InvokeAsync(this.onBeginObtenerHabitacionesPaginadoDelegate,
                new object[] { tipoConsulta, criterio, indice }, this.onEndObtenerHabitacionesPaginadoDelegate, customObtenerCatalogosDelegate, null);
        }

        public void GuardarHabitacionAsync(Habitacion habitacion, Action<AsyncCompletedEventArgs> method)
        {
            if ((this.onBeginGuardarHabitacionDelegate == null))
            {
                this.onBeginGuardarHabitacionDelegate = new BeginOperationDelegate(this.OnBeginGuardarHabitacion);
            }
            if ((this.onEndGuardarHabitacionDelegate == null))
            {
                this.onEndGuardarHabitacionDelegate = new EndOperationDelegate(this.OnEndGuardarHabitacion);
            }

            System.Threading.SendOrPostCallback customObtenerCatalogosDelegate = new System.Threading.SendOrPostCallback(
            state =>
            {
                if (method != null)
                {
                    InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                    AsyncCompletedEventArgs eventArg = new AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState);
                    if (!WcfProxyInvoker.ExistenErroresAsync(eventArg.Error))
                        Deployment.Current.Dispatcher.BeginInvoke(method, eventArg);
                }
            }
            );

            base.InvokeAsync(this.onBeginGuardarHabitacionDelegate,
                new object[] { habitacion }, this.onEndGuardarHabitacionDelegate, customObtenerCatalogosDelegate, null);
        }
    }
}
